using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ForumExplorer.Extension.Tagging
{
    public partial class NewAccount : Form
    {
        private Tagging taggingService;
        public NewAccount()
        {
            InitializeComponent();
            taggingService = new Tagging();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (this.textBoxPassword1.Text == this.textBoxPassword2.Text)
            {
                int created = taggingService.CreateNewAccount(this.textBoxUserName.Text, this.textBoxPassword1.Text, this.textBoxSecretPhrase.Text);
                if (created == 1)
                {
                    MessageBox.Show("The user " + this.textBoxUserName.Text + " was created!");
                    this.Close();
                }
                else if (created == 0)
                    MessageBox.Show("The creation of the user account failed.  Please check on the moderator forums and ensure you have the correct secret phrase.");
                else
                    MessageBox.Show("The username entered already exists.  Please try another username.");
            }
            else
                MessageBox.Show("The passwords entered do not match.  Please re-enter your password.");
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}